-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(meetings): Add endpoint to get writable calendars and the defaul… #13964
feat(meetings): Add endpoint to get writable calendars and the defaul… #13964
Conversation
…t calendar Signed-off-by: Joas Schilling <[email protected]>
… default calendar
Noticed that default calendar has a color 'null'. Is it also the case for you, and is it on our side? In calendar app i see it as purple, but maybe that's a fallback |
Color can be null, yes (as defined on the API). In that case you should use the primary color. |
protected function getSchedulingCalendarFromPropertiesTable(string $userId) { | ||
$propertyPath = 'principals/users/' . $userId; | ||
$propertyName = '{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL'; | ||
|
||
$query = $this->db->getQueryBuilder(); | ||
$query->select('propertyvalue') | ||
->from('properties') | ||
->where($query->expr()->eq('userid', $query->createNamedParameter($userId))) | ||
->andWhere($query->expr()->eq('propertypath', $query->createNamedParameter($propertyPath))) | ||
->andWhere($query->expr()->eq('propertyname', $query->createNamedParameter($propertyName))) | ||
->setMaxResults(1); | ||
|
||
$result = $query->executeQuery(); | ||
$property = $result->fetchOne(); | ||
$result->closeCursor(); | ||
|
||
return $property; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should go through the DAV app to get the default calendar URI, or you can use the user config:
$uri = $this->appConfig->getUserValue($userId, 'dav', 'defaultCalendar', CalDavBackend::PERSONAL_CALENDAR_URI);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, should use that preference,
but going through the dav app is to risky as it's all private api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@st3iny any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the setting can only be set by admins and is currently not documented. It acts as an override but will not be configured at all in most cases (see nextcloud/server#19852).
The official way would be to go through the CalDAV API and extract the default calendar from the principal's node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exemplary code:
$result = $this->server->getProperties(
$principalUri,
['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL'],
);
$calendarPath = $result['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL']->getHref();
Taken from: \Sabre\CalDAV\Schedule\Plugin::scheduleLocalDelivery
This requires access to an instance of \Sabre\DAV\Server
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternative: Do a PROPFIND
request to the CalDAV backend.
curl \
-u admin:admin \
--data @propfind.xml \
-X PROPFIND \
-H 'Content-Type: application/xml' \
-H 'Depth: 0' \
https://localhost/remote.php/dav/principals/users/admin
Request body (propfind.xml
)
<d:propfind xmlns:d="DAV:" xmlns:cd="urn:ietf:params:xml:ns:caldav">
<d:prop>
<cd:schedule-default-calendar-URL />
</d:prop>
</d:propfind>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Options
- Settings up a DAV server in OCS
- Doing a DAV request from client side
- Stick with the hacky query and add the preference check before that
My POV
- In my opinion 1. is not possible. We would have to make sure that so many things are chained together in the right order, all apps are loaded, etc. That's not suitable.
- Doable/best option from API side, but requires clients to send a DAV request, but I think they all have something already for file uploads, but not sure those libs also allow caldav. Additionally it's also unfortunate that this basically means we have to do 2 requests. First one to get the calendars with write permissions, Second one to get the default target one.
- Basically there already and could be finished in no time
Since we are on feature freeze today, I will check with the assigned frontender if they can do it quickly with 2, otherwise we go with 3 for now.
Frontend is now talking CalDAV to get the calendar list and default calendar, so we will not add this. |
Still need the POST endpoint |
Replacement at #14073 |
…t calendar
☑️ Resolves
🛠️ API Checklist
🚧 Tasks
schedule-meeting
will be added once all APIs are implemented🏁 Checklist
docs/
has been updated or is not required